package com.jia.together.controller;


import com.jia.together.entity.CourseType;
import com.jia.together.service.CourseTypeService;
import com.jia.together.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dujiajia
 * @since 2021-02-19
 */
@RestController
@RequestMapping("/courseType")
public class CourseTypeController {

    @Autowired
    private CourseTypeService courseTypeService;

    @GetMapping("/list")
    public R list(@RequestParam Long pageNum,@RequestParam Long pageSize) {
        Map<String,Object> map = courseTypeService.selectPageList(pageNum,pageSize);
        return R.ok().data(map);
    }
    @GetMapping("/info/{id}")
    public R info(@PathVariable String id){
        CourseType byId = courseTypeService.getById(id);
        return R.ok().data("data",byId);
    }
    @PostMapping("/add")
    public R add(@RequestBody CourseType courseType){
        courseTypeService.save(courseType);
        return R.ok();
    }
    @PutMapping("/update")
    public R update(@RequestBody CourseType courseType){
        courseTypeService.updateById(courseType);
        return R.ok();
    }
    @DeleteMapping("/delete/{id}")
    public R delete(@PathVariable String id){
        courseTypeService.removeById(id);
        return R.ok();
    }
}

